﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace DCS7GUI
{
    public class GUIRLargeWin : IDCSGUI, IGUIContainer
    {
        public GUIRLargeWin()
        {
            Controls = new List<IDCSGUI>();
            Controls.Add(new GUIRText()
            {
                Text = "Hello World!",
                X = 0,
                Y = 0,
                Parent = this,
            });
            Controls.Add(new GUIRWinButtons()
            {
                Close = true,
                Minimize = true,
                Maximize = true,
                Parent = this,
            });
        }

        #region IDCSGUI Members

        public string Sprite { get; set; }
        public string Title { get; set; }

        public byte Size
        {
            get { return (byte)(Title.Length + 6); }
        }

        public byte Type
        {
            get { return 1; }
        }

        public string Data
        {
            get
            {
                return "\"" + Title + "\", 0\n" + Sprite;
            }
        }

        public Bitmap Render(Bitmap image, int offsetX, int offsetY)
        {
            Helpers.DrawRectangle(0, 0, 96, 9, image);
            Helpers.EmptyRectangle(0, 0, 96, 64, image);
            Helpers.PixelOff(0, 0, image);
            Helpers.PixelOff(95, 0, image);
            Helpers.PixelOff(95, 63, image);
            Helpers.PixelOff(0, 63, image);
            Helpers.DrawText(8, 2, Title, image);
            Helpers.DrawSprite(88, 1, new byte[] { 0x7C, 0x82, 0xAA, 0x92, 0xAA, 0x82, 0x7C, }, image);
            Helpers.DrawSprite(2, 2, Helpers.HexToBytes(Sprite), image);
            foreach (IDCSGUI item in Controls)
                item.Render(image, 1, 9);
            return image;
        }

        public List<IDCSGUI> Controls { get; set; }

        public byte Width
        {
            get { return 96; }
            set { }
        }

        public byte Height
        {
            get { return 64; }
            set { }
        }

        public byte X
        {
            get { return 0; }
            set { }
        }

        public byte Y
        {
            get { return 0; }
            set { }
        }

        public int deltaX
        {
            get
            {
                return 1;
            }
        }

        public int deltaY
        {
            get
            {
                return 9;
            }
        }

        public IGUIContainer Parent { get; set; }

        #endregion
    }
}
